package com.song.springclouddemoshardingjdbc.mapper;

import com.song.springclouddemoshardingjdbc.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface UserMapper {

    @Insert("insert into user(nickname,password,sex,age,birthday,dbname) values(#{nickname},#{password},#{sex},#{age},#{birthday},#{dbname})")
    void addUser(User user);

    @Select("select * from user")
    List<User> findUsers();


    @Select("select * from user limit #{page}, #{size}")
    List<User> findUserByPage(Map<String, Object> params);

    @Select("select count(1) from user")
    long findUserCount();

}
